#include <stdio.h>
#include <unistd.h>

int gval = 100;

int main()
{
    __pid_t id = fork();
    if(id == 0)
    {
        while(1)
        {
            printf("子进程: gval: %d, &gval: %p, pid: %d\n", gval, &gval, getpid());
            gval++;
            sleep(1);
        }
    }
    else
    {
        while(1)
        {
            printf("父进程: gval: %d, &gval: %p\n", gval, &gval);
            sleep(1);
        }
    }

    return 0;
}